﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
using TagLib;

namespace Backup_Manager_3CHIF
{
    abstract class Item
    {
        protected String path;
        protected String title;
        protected ArrayList tags = new ArrayList();

        public string Title {
            get { return title; }
        }

        public Item(String path, String title){
            if(System.IO.File.Exists(path))this.path=path;
            else throw new Exception("OMG File Not Found!!");
            this.title = title;
            TagLib.File f = TagLib.File.Create(path);
            tags.Add(f.Tag.Title);
            tags.Add(f.Tag.FirstPerformer);
            tags.Add(f.Tag.Album);
        }

        
        public bool addTag(String s)
        {
            if (this.hasTag(s)) return false;
            tags.Add(s);
            return true;
        }

        public bool hasTag(String s)
        {
            return tags.Contains(s);
        }

        public bool removeTag(String s) {
            if (!this.hasTag(s)) return false;
            tags.Remove(s);
            return true;
        }

        public String[] getTags()
        {
            return (String[])tags.ToArray();
        }

        public String getPath() {
            return path;
        }

        public abstract void play();

        public override String ToString() {
            return title;
        }
        }
    }

